package com.slz3.business.module.messageManagement.mesActivity.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.messageManagement.mesActivity.domain.MesActivity;
import com.slz3.business.module.messageManagement.mesActivity.domain.MesActivityCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class MesActivityResController {

    @Resource
    private MesActivityResAtomic mesActivityResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, MesActivity mesActivity) {
        if (MesActivityResUnsafeValid.add(req, mesActivity)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.add_$MesActivityUpdateLock(req, mesActivity);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, MesActivityCondition mesActivityCondition) {
        if (MesActivityResUnsafeValid.delete(req, mesActivityCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.delete_$MesActivityUpdateLock(req, mesActivityCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, MesActivity mesActivity) {
        if (MesActivityResUnsafeValid.modify(req, mesActivity)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.modify_$MesActivityUpdateLock(req, mesActivity);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (MesActivityResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesActivityResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return mesActivityResAtomic.info_$MesActivityUpdateLock(req);
        if (MesActivityResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.info_$MesActivityUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (MesActivityResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesActivityResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, MesActivityCondition mesActivityCondition) {
        //
        if (MesActivityResUnsafeValid.auditSubmit(req, mesActivityCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.auditSubmit_$MesActivityUpdateLock(req, mesActivityCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, MesActivityCondition mesActivityCondition) {
        if (MesActivityResUnsafeValid.audit(req, mesActivityCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.audit_$MesActivityUpdateLock(req, mesActivityCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, MesActivityCondition mesActivityCondition) {
        if (MesActivityResUnsafeValid.auditReject(req, mesActivityCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.auditReject_$MesActivityUpdateLock(req, mesActivityCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, MesActivityCondition mesActivityCondition) {
        if (MesActivityResUnsafeValid.usingEnable(req, mesActivityCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.usingEnable_$MesActivityUpdateLock(req, mesActivityCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, MesActivityCondition mesActivityCondition) {
        if (MesActivityResUnsafeValid.usingDisable(req, mesActivityCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesActivityResAtomic.usingDisable_$MesActivityUpdateLock(req, mesActivityCondition);
        }
    }

}
